package com.xposed.aliproxy.thread;

import android.content.Context;

import com.xposed.aliproxy.R;
import com.xposed.aliproxy.db.AliTradeModel;
import com.xposed.aliproxy.db.DBUtil;
import com.xposed.aliproxy.http.HttpBase;
import com.xposed.aliproxy.http.HttpManager;
import com.xposed.aliproxy.qrcode.GlobalInstance;
import com.xposed.aliproxy.utils.JsonUtil;
import com.xposed.aliproxy.utils.ParamConfig;
import com.xposed.aliproxy.utils.Utils;

import org.json.JSONObject;
import de.robv.android.xposed.XposedBridge;

/* renamed from: h.g */
public class UploadAliTradeThread extends Thread {
    /* renamed from: a */
    private Context f1805a;
    /* renamed from: b */
    private AliTradeModel f1806b;
    /* renamed from: c */
    private String f1807c;
    /* renamed from: d */
    private String f1808d;
    /* renamed from: e */
    private String f1809e;

    public UploadAliTradeThread(Context context, AliTradeModel aliTradeModel) {
        this.f1805a = context;
        this.f1806b = aliTradeModel;
        this.f1807c = ParamConfig.getInstance(context).getString("aliAccount", "");
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(HttpManager.getSpliceUrl(context));
        stringBuilder.append("payform");
        this.f1808d = stringBuilder.toString();
    }

    public void run() {
        super.run();
        try {
            if (GlobalInstance.getInstance().f1765d) {
                this.f1809e = "1";
            } else {
                this.f1809e = "0";
            }
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("aid", "1");
            jSONObject.put("termType", "2");
            jSONObject.put("transType", "G001");
            jSONObject.put("title", this.f1806b.getName());
            jSONObject.put("tradeTime", this.f1806b.getDate());
            jSONObject.put("money", this.f1806b.getAmount());
            jSONObject.put("respMsg", "支付成功");
            jSONObject.put("respCode", "00");
            jSONObject.put("orderNo", this.f1806b.getTradeNo());
            jSONObject.put("inAccount", this.f1807c);
            jSONObject.put("balance", this.f1806b.getAliBalance());
            jSONObject.put("qrCodeRemark", this.f1806b.getRemark());
            jSONObject.put("isLogin", this.f1809e);
            jSONObject.put("sign", Utils.formatJson(jSONObject, this.f1805a.getString(R.string.app_xposed_jka)));
            String a = JsonUtil.getString(new JSONObject(HttpBase.m2919a(this.f1808d, jSONObject.toString(), null)), "status");
            if ("0".equals(a) || "11".equals(a) || "10".equals(a)) {
                DBUtil.getInstance(this.f1805a).updateAlitrade(this.f1806b.getTradeNo(), "1");
            }
        } catch (Throwable th) {
            XposedBridge.log(th);
        }
    }
}
